import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: 'Dashboard', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/information', // 资料
    redirect: '/information/project',
    name: 'Information',
    alwaysShow: true,
    component: Layout,
    meta: {
      title: 'Information',
      icon: 'Information'
    },
    children: [
      {
        path: 'constant', // 常量列表
        component: () => import('@/views/information/constant/index'),
        name: 'Constant',
        meta: { title: 'constant' }
      },
      {
        path: 'fund', // 资金构成
        component: () => import('@/views/information/fund/index'),
        name: 'Fund',
        meta: { title: 'fund' }
      }
    ]
  },
  {
    path: '/moveBrick', // 搬砖
    component: Layout,
    redirect: '/dashboard',
    name: 'MoveBrick',
    meta: {
      title: 'MoveBrick',
      icon: 'moveBrick'
    },
    children: [
      {
        path: 'steam', // steam订单
        component: () => import('@/views/moveBrick/steam/index'),
        name: 'Steam',
        meta: { title: 'Steam' }
      },
      {
        path: 'steamWarehouse', // steam交易
        component: () => import('@/views/moveBrick/steamWarehouse/index'),
        name: 'steamWarehouse',
        meta: { title: 'SteamWarehouse' }
      },
      {
        path: 'buffGoods', // buff选货
        component: () => import('@/views/moveBrick/buffGoods/index'),
        name: 'buffGoods',
        meta: { title: 'BuffGoods' }
      }
    ]
  },
  {
    path: '/videoClip', // 剪辑
    component: Layout,
    redirect: '/dashboard',
    name: 'VideoClip',
    meta: {
      title: 'VideoClip',
      icon: 'videoClip'
    },
    children: [
      {
        path: 'cilp', // 剪辑订单
        component: () => import('@/views/videoClip/cilp/index'), // Parent router-view
        name: 'cilp',
        meta: { title: 'Clip' }
      },
      {
        path: 'orderTaking', // 剪辑接单
        component: () => import('@/views/videoClip/orderTaking/index'),
        name: 'OrderTaking',
        meta: { title: 'OrderTaking' }
      }
    ]
  },
  {
    path: '/fundStocks', // 资金盘
    component: Layout,
    redirect: '/dashboard',
    alwaysShow: true,
    name: 'fundStocks',
    meta: {
      title: 'fundStocks',
      icon: 'fundStocks'
    },
    children: [
      {
        path: 'fundingProject', // 资金项目
        component: () => import('@/views/fundStocks/fundingProject/index'), // Parent router-view
        name: 'fundingProject',
        meta: { title: 'fundingProject' }
      }
    ]
  },
  {
    path: '/capital', // 资金盘
    component: Layout,
    redirect: '/dashboard',
    alwaysShow: true,
    name: 'capital',
    meta: {
      title: 'capital',
      icon: 'capital'
    },
    children: [
      {
        path: 'capitalProject', // 资金项目
        component: () => import('@/views/capital/capitalProject/index'), // Parent router-view
        name: 'capitalProject',
        meta: { title: 'capitalProject' }
      }
    ]
  },
  {
    path: '/report', // 报表
    component: Layout,
    redirect: '/dashboard',
    name: 'Report',
    meta: {
      title: 'Report',
      icon: 'report'
    },
    children: [
      {
        path: 'moveTable', // 搬砖
        component: () => import('@/views/report/moveTable/index'),
        name: 'moveTable',
        meta: { title: 'MoveTable' }
      },
      {
        path: 'cilpTable', // 剪辑
        component: () => import('@/views/report/cilpTable/index'),
        name: 'cilpTable',
        meta: { title: 'CilpTable' }
      },
      {
        path: 'capitalTable', // 资金盘
        component: () => import('@/views/report/capitalTable/index'),
        name: 'capitalTable',
        meta: { title: 'capitalTable' }
      }
    ]
  },
  {
    path: '/received', // 到账
    component: Layout,
    redirect: '/dashboard',
    name: 'Received',
    meta: {
      title: 'Received',
      icon: 'received'
    },
    children: [
      {
        path: 'moveMoney', // 搬砖
        component: () => import('@/views/received/moveMoney/index'),
        name: 'moveMoney',
        meta: { title: 'moveMoney' }
      },
      {
        path: 'cilpMoney', // 剪辑
        component: () => import('@/views/received/cilpMoney/index'),
        name: 'cilpMoney',
        meta: { title: 'cilpMoney' }
      },
      {
        path: 'capitalMoney', // 资金盘
        component: () => import('@/views/received/capitalMoney/index'),
        name: 'capitalMoney',
        meta: { title: 'capitalMoney' }
      }
    ]
  }
]

const createRouter = () =>
  new Router({
    // mode: 'hash',
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
